SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[spDifDiasHabiles] 
@FDesde datetime,
@FHasta datetime
AS
SET NOCOUNT ON
set dateformat dmy

declare @dh int
declare @dw1 int
declare @dw2 int

select @dw1=DatePart(dw,@FDesde), @dw2=DatePart(dw,@FHasta), @dh=(datediff(day,@FDesde,@FHasta)+ 1 - (datediff(wk,@FDesde,@FHasta)*2))
if @dw1=6 
	select @dh=@dh-1
if @dw2=7
	select @dh=@dh-1

return (@dh)
GO
